# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

class ApplicationController < ActionController::Base
  # Pick a unique cookie name to distinguish our session data from others'
  session :session_key => '_dizhen.1kg.org_session_id'
  include AuthenticatedSystem
  before_filter :unread_messages_amount
  
  protected
  def unread_messages_amount
    return if !logged_in?
    @unreads = Message.count(:all, :conditions => {:receiver_id => current_user.id,
                                                   :unread      => true})
  end
end
